<?php 
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: edit.phtml 4182 2010-08-01 16:27:10Z huuphuoc $
 * @since		2.0.0
 */
?>
<?php 
$this->headTitle($this->translator('client_edit_page_title'));
$this->headLink()->appendStylesheet($this->APP_STATIC_SERVER . '/skins/admin/default/css/form.css');
$this->headScript()->appendFile($this->APP_STATIC_SERVER . '/js/jquery.validate.min.js');
?>

<div id="r-heading">
    <img src="<?php echo $this->APP_STATIC_SERVER . '/skins/admin/default/images/client.png'; ?>" alt=""/>
    <span><a href="<?php echo $this->url(array(), 'ad_client_list'); ?>"><?php echo $this->translator('client_list_breadcrumb'); ?></a></span>
    <span><?php echo $this->translator('client_add_breadcrumb'); ?></span>
</div>
<?php
$message = $this->flashMessenger();
if ($message) {
    ?>
    <div id="message"><ul><?php echo $message; ?></ul></div>
<?php } ?>


<form method="post" action="<?php echo $this->url(array('id' => $this->client->id), 'ad_client_edit'); ?>" id="addClientForm">
    <div class="row">
        <label><?php echo $this->translator('client_name'); ?>:</label>
        <input type="text" id="name" name="name" style="width: 400px" value="<?php echo $this->client->name?>"/>
    </div>
    <div class="row">
        <label><?php echo $this->translator('client_email'); ?>:</label>
        <input type="text" id="email" name="email" style="width: 200px" value="<?php echo $this->client->email?>"/>
    </div>
    <div class="row">
        <label><?php echo $this->translator('client_telephone'); ?>:</label>
        <input type="text" id="telephone" name="telephone" style="width: 200px" value="<?php echo $this->client->telephone?>"/>
    </div>
    <div class="row">
        <label><?php echo $this->translator('client_address'); ?>:</label>
        <textarea name="address" id="address" style="width: 400px; height: 100px"><?php echo $this->client->address?></textarea>
    </div>
    <div class="row">
        <button class="button" type="submit"><span><?php echo $this->translator('client_edit_save_button'); ?></span></button>
    </div>
</form>

<script type="text/javascript">
    $(document).ready(function() {
        /**
         * Validate form
         */
        $('#addClientForm').validate({
            rules: {
                name: {
                    required: true
                },
                email: {
                    email: true
                },
                telephone:{
                    digits: true
                }
            },
            messages: {
                name: {
                    required: "<?php echo $this->translator('client_name_required'); ?>"
                },
                email: { 
                    email: "<?php echo $this->translator('client_email_invalid'); ?>"
                },
                telephone: {
                    digits: "<?Php echo $this->translator('client_phone_invalid');?>"
                }
            }
        });
    });
</script>